namespace CarSales.Migrations
{
    using CarSales.Models;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<CarSales.Models.CarSalesDB>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

        protected override void Seed(CarSales.Models.CarSalesDB context)
        {
            context.Owners.AddOrUpdate(r => r.OwnName,
                new Owner
                {
                    OwnName = "Jignesh",
                    OwnAddress1 = "5 Luton Road",
                    OwnAddress2 = "Blacktown",
                    OwnContactEmail = "jipatel@gmail.com",
                    OwnContactPhone = "0433958420",
                    OwnState = "NSW",
                    OwnSuburb = "Blacktown",
                    Cars = new List<Car> {new Car{ CarMake = "Toyota", CarModel = "Aurion", CarColor = "Red", CarDateEntered = DateTime.Now, CarDateUpdated = DateTime.Now, CarShortDescription = "Amazing Car", CarLongDescription = "Amazing Car" },
                                          new Car{ CarMake = "Holden", CarModel = "Commodore", CarColor = "White", CarDateEntered = DateTime.Now, CarDateUpdated = DateTime.Now, CarShortDescription = "Amazing Car", CarLongDescription = "Amazing Car" }}
                });

            for (int i = 0; i < 100; i++) {
                context.Owners.AddOrUpdate(r => r.OwnName,
                    new Owner { 
                        OwnName = "Jignesh" + i.ToString(),
                        OwnAddress1 = "5 Luton road",
                        OwnAddress2 = "Blacktown",
                        OwnContactEmail=  "jigneshpatel@gmail.com",
                        OwnContactPhone= "0433999999",
                        OwnState = "NSW",
                        OwnSuburb = "Blacktown",
                        Cars = new List<Car>{
                            new Car { CarMake= "Toyota"+ i.ToString(), CarModel = "Aurion", CarColor = "Liquid Matalic", CarDateEntered = DateTime.Now, CarDateUpdated = DateTime.Now, CarShortDescription = "Amasing car", CarTitle = "Toyota Aurion" + i.ToString(), CarLongDescription = "One owner always garaged",
                                ImageResources = new List<ImageResource>{
                                    new ImageResource{ ImgName=  "car_1.jpg", ImgLocation = "Img/Cars", ImgPrimary = true },
                                    new ImageResource{ ImgName=  "car_2.jpg", ImgLocation = "Img/Cars" },
                                    new ImageResource{ ImgName=  "car_3.jpg", ImgLocation = "Img/Cars" },
                                    new ImageResource{ ImgName=  "car_4.jpg", ImgLocation = "Img/Cars" },
                                    new ImageResource{ ImgName=  "car_5.jpg", ImgLocation = "Img/Cars" },
                                }    
                            }
                        }
                    });
                   
            }
        }
    }
}
